import React, { lazy, Suspense } from "react";
import {
  HashRouter as Router,
  Route,
  Switch,
  Redirect,
} from "react-router-dom";
import config from "../config";
let HomeComponent = lazy(() => import("../pages/home/home"));

class RouterComponent extends React.Component {
  render() {
    return (
      <React.Fragment>
        <Router>
          <Suspense fallback={<div>loading</div>}>
            <React.Fragment>
              <Switch>
                {/* 一级路由 */}
                <Route
                  path={config.path + "home"}
                  component={HomeComponent}
                ></Route>
                <Redirect to={config.path + "home/index"}></Redirect>
              </Switch>
            </React.Fragment>
          </Suspense>
        </Router>
      </React.Fragment>
    );
  }
}

export default RouterComponent;
